let productId = getQuery("productId")

window.onload = function () {
    initProduct(productId)
}

function initProduct(productId) {
    axios.get("/product/showProduct",{
        params:{productId}
    }).then(resp =>{
        if (resp.data != ""){
            let info = resp.data
            $('productImg').src = "/productImg/"+info.imgPath
            $('nameDiv').innerHTML = info.name
            $('priceDiv').innerHTML = info.price
            $('areaDiv').innerHTML = info.area
            $('dateDiv').innerHTML = info.createDate
            $('sealDiv').innerHTML = info.sealNum
        }
    })
}

function buy(productId) {
    axios.get("/shop/buy",{
        params: {productId}
    }).then(resp =>{
        if (resp.data=="ok"){
            location.href = "/custom/shop.html"
        }else{
            location.href = "/login.html?errorInfo=noCustom"
        }
    })

}
